const { Controller } = require('egg');

class HomeController extends Controller {
  async index() {
    const { ctx } = this;
    await ctx.render('./index.html', { test: 1 });
  }
  async simple() {
    const { ctx } = this;
    await ctx.render('./simple.html', { test: 1 });
  }
  async sse() {
    const { ctx } = this;
    try {
      ctx.aaa = '12345';
      const res = await ctx.service.aiService.queryAI();

      ctx.body = res;// 返回AI的响应
    } catch (error) {
      ctx.status = 500;
      console.error(error);
      ctx.body = { error: 'An error occurred while processing your request.' };
    }
  }
}

module.exports = HomeController;
